import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { getQuestionById } from '../services/question';
import { useRequest } from 'ahooks';
export default function useLoadQuestionData() {
    const { id = '' } = useParams();
    // const [loading, setLoading] = useState(true);
    // const [question, setQuestion] = useState<any>({});
    // useEffect(() => {
    //     getQuestionById(id as string).then(res => {
    //         setQuestion(res);
    //         setLoading(false);
    //     });
    // }, []);
    async function fun() {
        const data = await getQuestionById(id as string);
        return data;
    }
    const { loading, data: question } = useRequest(fun);

    return { loading, question };
}
